package cn.wolfcode.wolf2w.job;


import cn.wolfcode.wolf2w.redis.service.IStrategyStatisVORedisService;
import cn.wolfcode.wolf2w.redis.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

//@Component
public class RedisDataPersitenceJob {
    @Autowired
    private IStrategyStatisVORedisService strategyStatisVORedisService;
    @Autowired
    private IStrategyService strategyService;

    @Scheduled(cron = "0/10 * * * * ?")
    public void doWork(){
        //方法中,先拿取所有VO对象
        List<StrategyStatisVO> list = strategyStatisVORedisService.queryStartegyVoByPattern("*");
        //遍历vo集合,调用服务方法,将vo==>strategy存入数据库
        for (StrategyStatisVO vo : list) {
            strategyService.saveVo(vo);
        }
    }
}
